package com.vortex.cloud.sample.utils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @author 王林
 * @version 1.0
 * @date 2021-10-25 周一
 * @time 14:30
 * @description 自定义注解
 */
public class MyIdentityValidator implements ConstraintValidator<MyIdentity, String> {


    @Override
    public void initialize(MyIdentity constraintAnnotation) {

        System.out.println("MyIdentity初始化中--------------");
    }

    @Override
    public boolean isValid(String o, ConstraintValidatorContext constraintValidatorContext) {

        System.out.println("MyIdentity开始验证--------------");
//        if (o != null) {
//            System.out.println(o.toString() + "=================");
//        }
        if (o == null || o.equals("")) {
            return false;
        }
        System.out.println("MyIdentity验证结束--------------");
        return true;
    }
}
